{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import tensorflow.keras as keras\n",
    "import tensorflow.keras.layers as layers\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "         0     1     2      3      4      5\n",
      "0     1.96  0.62  0.94  69.58  98.39  55.54\n",
      "1     1.84  0.68  0.87  77.94  30.09  55.24\n",
      "2     1.53  0.71  0.81  73.18 -22.10  40.71\n",
      "3     1.21  0.71  0.72  52.25 -39.25  19.35\n",
      "4     0.98  0.69  0.62  20.39 -35.34  -0.92\n",
      "...    ...   ...   ...    ...    ...    ...\n",
      "6995 -0.31  0.96 -0.15   0.79   0.18   2.32\n",
      "6996 -0.36  0.96 -0.13   2.50  -1.04   1.04\n",
      "6997 -0.36  0.95 -0.14   2.14   0.00   0.49\n",
      "6998 -0.37  0.95 -0.15   0.43   0.67   1.77\n",
      "6999 -0.37  0.95 -0.16  -1.34  -1.34   0.67\n",
      "\n",
      "[7000 rows x 6 columns]\n",
      "         0     1     2       3       4       5\n",
      "0    -0.49  1.55 -1.63 -216.99  367.44 -317.70\n",
      "1    -0.90 -1.98 -1.87 -204.29  170.96 -265.88\n",
      "2    -1.01 -1.98 -1.87 -214.42  -27.53 -171.76\n",
      "3    -1.09 -1.98 -1.87 -206.00 -166.39  -93.57\n",
      "4    -1.00 -1.98 -1.70 -153.81 -160.71  -39.12\n",
      "...    ...   ...   ...     ...     ...     ...\n",
      "6995 -0.77  0.62  0.32    9.28    5.92    1.28\n",
      "6996 -0.84  0.62  0.31   17.33   -4.27   -3.91\n",
      "6997 -0.90  0.61  0.29   20.63  -10.25   -3.42\n",
      "6998 -0.93  0.62  0.28   17.94  -10.74    1.16\n",
      "6999 -0.91  0.63  0.29   11.47   -8.42    5.25\n",
      "\n",
      "[7000 rows x 6 columns]\n"
     ]
    }
   ],
   "source": [
    "punch = pd.read_csv('data/punch.csv', header = None)\n",
    "flex = pd.read_csv('data/flex.csv', header = None)\n",
    "print(punch)\n",
    "print(flex)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "SAMPLES_PER_GESTURE = 70"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def processData(d, v):\n",
    "    dataX = np.empty([0,SAMPLES_PER_GESTURE*6])\n",
    "    dataY = np.empty([0])\n",
    "\n",
    "    data  = d.values\n",
    "    dataNum = data.shape[0] // SAMPLES_PER_GESTURE\n",
    "\n",
    "\n",
    "    for i in tqdm(range(dataNum)):\n",
    "        tmp = []\n",
    "        for j in range(SAMPLES_PER_GESTURE):\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][0] + 4.0) / 8.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][1] + 4.0) / 8.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][2] + 4.0) / 8.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][3] + 2000.0) / 4000.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][4] + 2000.0) / 4000.0]\n",
    "            tmp += [(data[i * SAMPLES_PER_GESTURE + j][5] + 2000.0) / 4000.0]\n",
    "\n",
    "        tmp = np.array(tmp)\n",
    "\n",
    "        tmp = np.expand_dims(tmp, axis = 0)\n",
    "\n",
    "        dataX = np.concatenate((dataX, tmp), axis = 0)\n",
    "        dataY = np.append(dataY, v)\n",
    "\n",
    "    return dataX, dataY"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 100/100 [00:00<00:00, 1503.21it/s]\n",
      "100%|██████████| 100/100 [00:00<00:00, 1708.58it/s]\n"
     ]
    }
   ],
   "source": [
    "punchX, punchY = processData(punch, 0)\n",
    "flexX, flexY = processData(flex, 1)\n",
    "dataX = np.concatenate((punchX, flexX), axis = 0)\n",
    "dataY = np.concatenate((punchY, flexY), axis = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 27 122  32 196 140 190 100 193 101 144  73  21 112 159 171  22 180   0\n",
      "  47 103  93  71  60 172  87  74  72 179  46 156  30 178  25 107  79  26\n",
      " 149 174  40  41 133  11  77  49  80  69 176  67  43  97 160  20 139  56\n",
      " 116  48 106 147  44   7  76  55 195  42 175 154 173 123 150  90  99 125\n",
      " 168 121  92 130  36 135  70 117  37 189 186 141  65 120 151 114  66 188\n",
      "  34  78 164 109 129  52 110  53 184  84  10  50 167  85 108  63  13 152\n",
      " 170  81   9 165 124 118 134 183  35 181 148 161  91  17 182  24  16 191\n",
      " 157 199 158 113  59 119 136  19  96 192   8  39   4  61  45 128 185 104\n",
      " 162 142  89  12  38  62  18 105 194   6  82  83  23  64 163 145 169  58\n",
      "  51 177 126 111  31 153  14  75   5 197  28  33  29 132   3 146  57 187\n",
      "  68  15 198 102 131  95 166  94 137  86   2  98 127 143   1  54 138 155\n",
      "  88 115]\n"
     ]
    }
   ],
   "source": [
    "permutationTrain = np.random.permutation(dataX.shape[0])\n",
    "print(permutationTrain)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0. 1. 0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 1. 1. 1. 0. 1. 0. 0. 1. 0. 0. 0. 1.\n",
      " 0. 0. 0. 1. 0. 1. 0. 1. 0. 1. 0. 0. 1. 1. 0. 0. 1. 0. 0. 0. 0. 0. 1. 0.\n",
      " 0. 0. 1. 0. 1. 0. 1. 0. 1. 1. 0. 0. 0. 0. 1. 0. 1. 1. 1. 1. 1. 0. 0. 1.\n",
      " 1. 1. 0. 1. 0. 1. 0. 1. 0. 1. 1. 1. 0. 1. 1. 1. 0. 1. 0. 0. 1. 1. 1. 0.\n",
      " 1. 0. 1. 0. 0. 0. 1. 0. 1. 0. 0. 1. 1. 0. 0. 1. 1. 1. 1. 1. 0. 1. 1. 1.\n",
      " 0. 0. 1. 0. 0. 1. 1. 1. 1. 1. 0. 1. 1. 0. 0. 1. 0. 0. 0. 0. 0. 1. 1. 1.\n",
      " 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 1. 0. 0. 1. 1. 1. 0. 1.\n",
      " 0. 0. 0. 1. 0. 0. 0. 1. 0. 1. 0. 1. 0. 0. 1. 1. 1. 0. 1. 0. 1. 0. 0. 0.\n",
      " 1. 1. 0. 0. 1. 1. 0. 1.]\n"
     ]
    }
   ],
   "source": [
    "dataX = dataX[permutationTrain]\n",
    "dataY = dataY[permutationTrain]\n",
    "print(dataY)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "vfoldSize = int(dataX.shape[0]/100*20)\n",
    "\n",
    "xTest = dataX[0:vfoldSize]\n",
    "yTest = dataY[0:vfoldSize]\n",
    "\n",
    "xTrain = dataX[vfoldSize:dataX.shape[0]]\n",
    "yTrain = dataY[vfoldSize:dataY.shape[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = keras.Sequential()\n",
    "model.add(keras.layers.Dense(32, input_shape =(6*SAMPLES_PER_GESTURE,), activation='relu'))\n",
    "model.add(keras.layers.Dense(16, activation='relu'))\n",
    "model.add(keras.layers.Dense(2, activation='softmax'))\n",
    "adam = keras.optimizers.Adam()\n",
    "model.compile(loss='sparse_categorical_crossentropy',\n",
    "              optimizer=adam,\n",
    "              metrics=['sparse_categorical_accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense (Dense)                (None, 32)                13472     \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 16)                528       \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 2)                 34        \n",
      "=================================================================\n",
      "Total params: 14,034\n",
      "Trainable params: 14,034\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 160 samples, validate on 40 samples\n",
      "Epoch 1/200\n",
      "160/160 [==============================] - 1s 9ms/sample - loss: 0.7605 - sparse_categorical_accuracy: 0.4812 - val_loss: 0.6861 - val_sparse_categorical_accuracy: 0.5000\n",
      "Epoch 2/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.7012 - sparse_categorical_accuracy: 0.4812 - val_loss: 0.6833 - val_sparse_categorical_accuracy: 0.9000\n",
      "Epoch 3/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.6795 - sparse_categorical_accuracy: 0.6375 - val_loss: 0.6829 - val_sparse_categorical_accuracy: 0.5000\n",
      "Epoch 4/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.6702 - sparse_categorical_accuracy: 0.6000 - val_loss: 0.6597 - val_sparse_categorical_accuracy: 0.5000\n",
      "Epoch 5/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.6521 - sparse_categorical_accuracy: 0.6625 - val_loss: 0.6408 - val_sparse_categorical_accuracy: 0.5000\n",
      "Epoch 6/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.6096 - sparse_categorical_accuracy: 0.6875 - val_loss: 0.5744 - val_sparse_categorical_accuracy: 0.8250\n",
      "Epoch 7/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.5867 - sparse_categorical_accuracy: 0.7250 - val_loss: 0.5532 - val_sparse_categorical_accuracy: 0.7500\n",
      "Epoch 8/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.4918 - sparse_categorical_accuracy: 0.8062 - val_loss: 0.4658 - val_sparse_categorical_accuracy: 0.8250\n",
      "Epoch 9/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.5046 - sparse_categorical_accuracy: 0.7563 - val_loss: 0.4097 - val_sparse_categorical_accuracy: 0.8500\n",
      "Epoch 10/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.3739 - sparse_categorical_accuracy: 0.8687 - val_loss: 0.3487 - val_sparse_categorical_accuracy: 0.8500\n",
      "Epoch 11/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.3020 - sparse_categorical_accuracy: 0.9125 - val_loss: 0.3371 - val_sparse_categorical_accuracy: 0.8500\n",
      "Epoch 12/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.3015 - sparse_categorical_accuracy: 0.8375 - val_loss: 0.2355 - val_sparse_categorical_accuracy: 0.9000\n",
      "Epoch 13/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.2392 - sparse_categorical_accuracy: 0.9312 - val_loss: 0.2056 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 14/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.2342 - sparse_categorical_accuracy: 0.8938 - val_loss: 0.2477 - val_sparse_categorical_accuracy: 0.8750\n",
      "Epoch 15/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1776 - sparse_categorical_accuracy: 0.9438 - val_loss: 0.1525 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 16/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1631 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.3944 - val_sparse_categorical_accuracy: 0.7750\n",
      "Epoch 17/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1484 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.1785 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 18/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1440 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.1374 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 19/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1398 - sparse_categorical_accuracy: 0.9438 - val_loss: 0.1393 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 20/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1072 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0951 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 21/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1428 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.1235 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 22/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1326 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.1357 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 23/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1497 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.0754 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 24/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1096 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0730 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 25/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1366 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.1276 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 26/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1432 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.2686 - val_sparse_categorical_accuracy: 0.8500\n",
      "Epoch 27/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1387 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.0933 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 28/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1048 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0980 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 29/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1108 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.1547 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 30/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1023 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0677 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 31/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0874 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0633 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 32/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1646 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.0735 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 33/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1072 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0617 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 34/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1087 - sparse_categorical_accuracy: 0.9375 - val_loss: 0.0777 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 35/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1168 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.3302 - val_sparse_categorical_accuracy: 0.8250\n",
      "Epoch 36/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1132 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.1557 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 37/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1097 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0611 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 38/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1089 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.1377 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 39/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1375 - sparse_categorical_accuracy: 0.9438 - val_loss: 0.1789 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 40/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1324 - sparse_categorical_accuracy: 0.9375 - val_loss: 0.1468 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 41/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1124 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0733 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 42/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1030 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0833 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 43/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1221 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.2380 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 44/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1379 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.1241 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 45/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0935 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0570 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 46/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0796 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.3898 - val_sparse_categorical_accuracy: 0.8500\n",
      "Epoch 47/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1269 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0570 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 48/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0811 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1345 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 49/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1131 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.0763 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 50/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1017 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0523 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 51/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0918 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1322 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 52/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0962 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.2073 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 53/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0966 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0498 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 54/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0829 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0515 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 55/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0929 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0444 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 56/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0972 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0609 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 57/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0603 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1293 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 58/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0899 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.2997 - val_sparse_categorical_accuracy: 0.8750\n",
      "Epoch 59/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1415 - sparse_categorical_accuracy: 0.9438 - val_loss: 0.0640 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 60/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0808 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0485 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 61/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0911 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0940 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 62/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1032 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0466 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 63/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1026 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0613 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 64/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0788 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0462 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 65/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0864 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1257 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 66/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0953 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0863 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 67/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0971 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0745 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 68/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1206 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0524 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 69/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1170 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.0902 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 70/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0954 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0501 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 71/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0636 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0492 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 72/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0736 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0924 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 73/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0753 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0451 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 74/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1089 - sparse_categorical_accuracy: 0.9375 - val_loss: 0.0450 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 75/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0739 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0640 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 76/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0920 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0912 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 77/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0883 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0878 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 78/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0864 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0622 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 79/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0721 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0982 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 80/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0744 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0403 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 81/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0760 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0509 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 82/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0931 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0774 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 83/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0754 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0865 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 84/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0856 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1299 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 85/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0912 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0512 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 86/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0817 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0734 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 87/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.1214 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0573 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 88/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0844 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0472 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 89/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1184 - sparse_categorical_accuracy: 0.9438 - val_loss: 0.0826 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 90/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0737 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1363 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 91/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1017 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0514 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 92/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0743 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.3466 - val_sparse_categorical_accuracy: 0.8250\n",
      "Epoch 93/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0735 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0931 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 94/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0782 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0950 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 95/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1027 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0760 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 96/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1062 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0449 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 97/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0930 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0634 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 98/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0835 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0548 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 99/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0965 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1169 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 100/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0788 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1677 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 101/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1151 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0920 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 102/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0610 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0906 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 103/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0941 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0456 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 104/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0850 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.1221 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 105/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0990 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.1222 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 106/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0654 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0673 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 107/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0877 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1428 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 108/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0975 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0558 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 109/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0738 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0857 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 110/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0663 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0553 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 111/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0741 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0572 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 112/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0634 - sparse_categorical_accuracy: 0.9875 - val_loss: 0.0921 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 113/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0884 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0469 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 114/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1266 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0489 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 115/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0861 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0764 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 116/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1100 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0588 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 117/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0730 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0906 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 118/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0675 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.2625 - val_sparse_categorical_accuracy: 0.9000\n",
      "Epoch 119/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1116 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0523 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 120/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0862 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0798 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 121/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0694 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0483 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 122/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0947 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0521 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 123/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0769 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0953 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 124/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0879 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1214 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 125/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0789 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1305 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 126/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0736 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0807 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 127/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0785 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0717 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 128/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0849 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0464 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 129/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0354 - sparse_categorical_accuracy: 0.9937 - val_loss: 0.1349 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 130/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0540 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0532 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 131/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0619 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0882 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 132/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0675 - sparse_categorical_accuracy: 0.9875 - val_loss: 0.0443 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 133/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0714 - sparse_categorical_accuracy: 0.9875 - val_loss: 0.0811 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 134/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0610 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0534 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 135/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1155 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0641 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 136/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0589 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0462 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 137/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0467 - sparse_categorical_accuracy: 0.9937 - val_loss: 0.0541 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 138/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0669 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0860 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 139/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1187 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0478 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 140/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0600 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0467 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 141/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0937 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.2355 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 142/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0793 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0658 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 143/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0587 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1944 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 144/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0836 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0444 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 145/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0755 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1108 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 146/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0697 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1052 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 147/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0628 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0461 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 148/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1136 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.0824 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 149/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0792 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0496 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 150/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0567 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1370 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 151/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0729 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0464 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 152/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0696 - sparse_categorical_accuracy: 0.9875 - val_loss: 0.0864 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 153/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1011 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0507 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 154/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0566 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1462 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 155/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0741 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0465 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 156/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0732 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0968 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 157/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0930 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0477 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 158/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0521 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0620 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 159/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0627 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0508 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 160/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0530 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1670 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 161/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0695 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.4865 - val_sparse_categorical_accuracy: 0.8000\n",
      "Epoch 162/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.1001 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0507 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 163/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0635 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0769 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 164/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0654 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1297 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 165/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0606 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1018 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 166/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0893 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0478 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 167/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0549 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0702 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 168/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0591 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0543 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 169/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0620 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1018 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 170/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0968 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.1564 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 171/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0956 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0454 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 172/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0582 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0446 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 173/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0817 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1729 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 174/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1288 - sparse_categorical_accuracy: 0.9563 - val_loss: 0.0438 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 175/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0838 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0619 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 176/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0580 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0551 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 177/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0405 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.2366 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 178/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0793 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0696 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 179/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0649 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1501 - val_sparse_categorical_accuracy: 0.9500\n",
      "Epoch 180/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0507 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1180 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 181/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0517 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0436 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 182/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0726 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.1354 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 183/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0560 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0435 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 184/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.1070 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0483 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 185/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0540 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0649 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 186/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0592 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0612 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 187/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0541 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0672 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 188/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0638 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0519 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 189/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0740 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0503 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 190/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0629 - sparse_categorical_accuracy: 0.9625 - val_loss: 0.0612 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 191/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0631 - sparse_categorical_accuracy: 0.9875 - val_loss: 0.0678 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 192/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0551 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.1075 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 193/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0573 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0669 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 194/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.0413 - sparse_categorical_accuracy: 0.9875 - val_loss: 0.2047 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 195/200\n",
      "160/160 [==============================] - 0s 3ms/sample - loss: 0.1215 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.2250 - val_sparse_categorical_accuracy: 0.9250\n",
      "Epoch 196/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0732 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0580 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 197/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0625 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0836 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 198/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0681 - sparse_categorical_accuracy: 0.9688 - val_loss: 0.0485 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 199/200\n",
      "160/160 [==============================] - 1s 4ms/sample - loss: 0.0738 - sparse_categorical_accuracy: 0.9750 - val_loss: 0.0487 - val_sparse_categorical_accuracy: 0.9750\n",
      "Epoch 200/200\n",
      "160/160 [==============================] - 1s 3ms/sample - loss: 0.0599 - sparse_categorical_accuracy: 0.9812 - val_loss: 0.0494 - val_sparse_categorical_accuracy: 0.9750\n"
     ]
    }
   ],
   "source": [
    "history = model.fit(xTrain, yTrain, batch_size=1, validation_data=(xTest, yTest), epochs=200, verbose=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "57716"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "converter = tf.lite.TFLiteConverter.from_keras_model(model)\n",
    "tflite_model = converter.convert()\n",
    "\n",
    "open(\"model\", \"wb\").write(tflite_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "!xxd -i model >> model.h"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
